﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 引入vue和axios -->
    <script src="js/plugins/vue/dist/vue.js"></script>
    <script src="js/plugins/axios/dist/axios.js"></script>
    <!-- axios全局配置 -->
    <script src="js/common.js"></script>
    <style>
        h2,h3{
            text-align: center;
        }
        h3{
            cursor: pointer;
        }
    </style>
</head>
<body>
<div id="app">
    <h1 style="text-align: center"> 服务下单 </h1>
    <h2>你购买的服务为 {{shop.name}}</h2>
    <h2>你所需要支付的价格为【 {{shop.saleprice}}元】</h2>
    <h3 style="color: red">您确认要支付吗 ？
        <span style="color: #07ee07" @click="ok">确认</span>
        <psan style="color: #5c6669" @click="no">取消</psan>
    </h3>
</div>

<script type="text/javascript">
    new Vue({
        el: "#app",
        data: {
            //图片显示的前前缀
            resourcePrefix: "http://123.207.27.208",
            //图片的后缀
            shop: {
                productDetail:{}
            },
            logininfo: null,
            resources: [], //数组
        },
        methods: {
            getShopDetail(productId) {
                this.$http.get("/product/" + productId).then(result => {
                    this.shop = result.data;
                })
            },

            ok(){
                this.$http.post("/product/accept",this.shop).then(res=>{
                    if(res.data.success){
                        alert("ok")
                        window.open("index.html")
                    }else {
                        alert("false")
                        location.href="productDetail.html?productId="+this.shop.id
                    }
                    alert("你好")
                }).catch(error => {
                    alert("系统繁忙")
                })
            },
            no(){
                location.href="productDetail.html?productId="+this.shop.id
            }

        },
        mounted() {
            this.logininfo = JSON.parse(localStorage.getItem("logininfo"));
            let productId = parseUrlParams2Obj(location.href).productId;
            this.getShopDetail(productId);
        }
    })
</script>
</body>
</html>